﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Data.Common;
using System.Data.SqlClient;
using System.Data;

namespace CAD.DAO
{
    public class DAORevaluos
    {
        public int Insertar(DateTime DTFECHA_DT, string sdescripcion, int LACTIVOS_ID, int concurrencia)
        {
            List<DbParameter> lstParametros = new List<DbParameter>();
            DbParameter prmA = new SqlParameter();
            prmA.DbType = DbType.Int32;
            prmA.ParameterName = "@LREVALUOS_ID";
            prmA.Direction = ParameterDirection.Output;
            lstParametros.Add(prmA);

            DbParameter prmB = new SqlParameter();
            prmB.DbType = DbType.DateTime;
            prmB.ParameterName = "@DTFECHA_DT";
            prmB.Value = DTFECHA_DT;
            prmB.Direction = ParameterDirection.Input;
            lstParametros.Add(prmB);

            DbParameter prmC = new SqlParameter();
            prmC.DbType = DbType.String;
            prmC.ParameterName = "@SDESCIPCION_DSC";
            prmC.Value = sdescripcion;
            prmC.Direction = ParameterDirection.Input;
            lstParametros.Add(prmC);

            DbParameter prmCe = new SqlParameter();
            prmCe.DbType = DbType.String;
            prmCe.ParameterName = "@ICONCURRENCIA";
            prmCe.Value = 1;
            prmCe.Direction = ParameterDirection.Input;
            lstParametros.Add(prmCe);

            DbParameter prmCez = new SqlParameter();
            prmCez.DbType = DbType.String;
            prmCez.ParameterName = "@LACTIVOS_ID";
            prmCez.Value = LACTIVOS_ID;
            prmCez.Direction = ParameterDirection.Input;
            lstParametros.Add(prmCez);
             
            DbParameter prmd = new SqlParameter();
            prmd.DbType = DbType.Int32;
            prmd.ParameterName = "@iEvento";
            prmd.Value = 1;
            prmd.Direction = ParameterDirection.Input;
            lstParametros.Add(prmd);

            SQLConexion conProxy = new SQLConexion();
            if (conProxy.EjecutarDML(lstParametros, "dbo.SPABM_REVALUOS"))
                return Convert.ToInt32(prmA.Value);
            return -1;

        }
        public bool Actualizar(int LREVALUOS_ID, DateTime DTFECHA_DT, string sdescripcion, int LACTIVOS_ID, int concurrencia)
        {
            List<DbParameter> lstParametros = new List<DbParameter>();

            DbParameter prmA = new SqlParameter();
            prmA.DbType = DbType.Int32;
            prmA.ParameterName = "@LREVALUOS_ID";
            prmA.Value = LREVALUOS_ID;
            prmA.Direction = ParameterDirection.Input;
            lstParametros.Add(prmA);


            DbParameter prmB = new SqlParameter();
            prmB.DbType = DbType.DateTime;
            prmB.ParameterName = "@DTFECHA_DT";
            prmB.Value = DTFECHA_DT;
            prmB.Direction = ParameterDirection.Input;
            lstParametros.Add(prmB);

            DbParameter prmC = new SqlParameter();
            prmC.DbType = DbType.String;
            prmC.ParameterName = "@SDESCIPCION_DSC";
            prmC.Value = sdescripcion;
            prmC.Direction = ParameterDirection.Input;
            lstParametros.Add(prmC);

            DbParameter prmCe = new SqlParameter();
            prmCe.DbType = DbType.String;
            prmCe.ParameterName = "@ICONCURRENCIA";
            prmCe.Value = concurrencia;
            prmCe.Direction = ParameterDirection.Input;
            lstParametros.Add(prmCe);

            DbParameter prmCez = new SqlParameter();
            prmCez.DbType = DbType.String;
            prmCez.ParameterName = "@LACTIVOS_ID";
            prmCez.Value = LACTIVOS_ID;
            prmCez.Direction = ParameterDirection.Input;
            lstParametros.Add(prmCez);

            DbParameter prmd = new SqlParameter();
            prmd.DbType = DbType.Int32;
            prmd.ParameterName = "@iEvento";
            prmd.Value = 2;
            prmd.Direction = ParameterDirection.Input;
            lstParametros.Add(prmd);
            SQLConexion conProxy = new SQLConexion();
            return conProxy.EjecutarDML(lstParametros, "dbo.SPABM_REVALUOS");
        }
        public bool Eliminar(int LREVALUOS_ID)
        {
            List<DbParameter> lstParametros = new List<DbParameter>();

            DbParameter prmA = new SqlParameter();
            prmA.DbType = DbType.Int32;
            prmA.ParameterName = "@LREVALUOS_ID";
            prmA.Value = LREVALUOS_ID;
            prmA.Direction = ParameterDirection.Input;
            lstParametros.Add(prmA);

            DbParameter prmd = new SqlParameter();
            prmd.DbType = DbType.Int32;
            prmd.ParameterName = "@iEvento";
            prmd.Value = 3;
            prmd.Direction = ParameterDirection.Input;
            lstParametros.Add(prmd);

            SQLConexion conProxy = new SQLConexion();
            return conProxy.EjecutarDML(lstParametros, "dbo.SPABM_REVALUOS");
        }
        public DataSet Traer()
        {
            List<DbParameter> lstParametros = new List<DbParameter>();
            DbParameter prmD = new SqlParameter();
            prmD.DbType = DbType.Int32;
            prmD.ParameterName = "@iEvento";
            prmD.Value = 4;
            prmD.Direction = ParameterDirection.Input;
            lstParametros.Add(prmD);
            SQLConexion conProxy = new SQLConexion();
            return conProxy.EjecutarConsulta(lstParametros, "dbo.SPABM_REVALUOS");
        }
        public DataSet TraerXId(int LREVALUOS_ID)
        {
            List<DbParameter> lstParametros = new List<DbParameter>();

            DbParameter prmA = new SqlParameter();
            prmA.DbType = DbType.Int32;
            prmA.ParameterName = "@LREVALUOS_ID";
            prmA.Value = LREVALUOS_ID;
            prmA.Direction = ParameterDirection.Input;
            lstParametros.Add(prmA);

            DbParameter prmD = new SqlParameter();
            prmD.DbType = DbType.Int32;
            prmD.ParameterName = "@iEvento";
            prmD.Value = 5;
            prmD.Direction = ParameterDirection.Input;
            lstParametros.Add(prmD);

            SQLConexion conProxy = new SQLConexion();
            return conProxy.EjecutarConsulta(lstParametros, "dbo.SPABM_REVALUOS");
        }
      
    }
}
